package leetcode;

public class LC51 {
    public static void main(String[] args) {
        LC51 lc51 = new LC51();
        System.out.println(lc51.searchMatrix(new int[][]{{1,3,5,7},{10,11,16,20},{23,30,34,60}},66));
    }
    public boolean searchMatrix(int[][] matrix, int target) {
        int h = 0;
        int l = matrix[0].length - 1;
        while(h <= matrix.length - 1 && l >= 0){
            if (matrix[h][l] == target) return true;
            if (matrix[h][l] > target) l--;
            else h++;
        }
        return false;
    }
}
